package com.bgi.uims.module.sys.menu.dto;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.struts2.json.annotations.JSON;

import com.bgi.uims.common.dto.Common;

/**
 * 
 * ClassName:Menu 
 * Function: TODO 
 * Reason:	 TODO 
 * @CreateDate:2015年3月25日 上午10:36:03
 * @author   WEN
 * @version  
 * @since    JDK 1.7
 * @see
 */
public class Menu extends Common{

	/**
	 * serialVersionUID:TODO(用一句话描述这个变量表示什么).
	 * @since JDK 1.7
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 菜单ID
	 */
	private String id;
	/**
	 * 菜单父节点ID
	 */
	private String parentId;
	/**
	 * 图标
	 */
	private String iconCls;
	/**
	 * 菜单名
	 */
	private String text;
	/**
	 * URL
	 */
	private String url;
	/**
	 * 序号
	 */
	private String menuIndex;
	/**
	 * 状态，默认open，有子菜单则为close(数据库不需要存储)
	 */
	@SuppressWarnings("unused")
	private String state;
	/**
	 * 子菜单
	 */
	@SuppressWarnings("rawtypes")
	private List children;
	/**
	 * 辅助属性，菜单父节点名称
	 */
	private String parentName;
	/**
	 * 辅助属性，ids
	 */
	private String[] ids;
	/**
	 * 辅助属性，是否选中
	 */
	private boolean checked;
	/**
	 * 辅助属性，是否选中
	 */
	private String checkedStr;
	/**
	 * 辅助属性，查询资源时，需要的角色ID
	 */
	private String rolesId;
	/**
	 * 辅助属性，查询不需要的菜单信息
	 */
	private String excludeId;
	/**
	 * 辅助属性，查询不需要的菜单信息
	 */
	private String[] excludeIds;
	
	private String createUser; 	// 记录建立者
	private String createTime; 	// 记录建立时间
	private String lastModifiedUser;// 最后修改者
	private String lastModifiedTime; 	// 最后修改时间
	/**
	 * 辅助属性，历史记录时，程序单独添加记录信息
	 */
	private Map<String,String>  specialHistory;
	/**
	 * 将对象的信息以map形式返回，作为存储日志信息时的比较和存储
	 */
	public Map annotationObject(){
		Map<String,String> results = new HashMap<String, String>();
		results.put("object","菜单");//必须有,对象描述
		results.put("table","sys_purviews");//必须有,表名描述
		results.put("tableId",this.id);//必须有,表名描述
		results.put("describe","菜单称名"+this.getText());//必须有,可以指定到具体某一条，即该条的独有特性,可以描述此记录
		results.put("菜单ID号", this.id);
		results.put("菜单名称", this.text);
		results.put("菜单图标", this.iconCls);
		results.put("菜单URL", this.url);
		results.put("菜单序号", this.menuIndex);
		results.put("上级菜单名称", this.parentName);
		results.put("SELECT查询不需要的菜单ID号", this.excludeId);
		Map<String,String> extendResults = new HashMap<String, String>();
		boolean flag = true;
		if(this.specialHistory != null){
			Iterator<String> keys =  this.specialHistory.keySet().iterator();
			while(keys.hasNext()){
				String key = keys.next();
				String value = this.specialHistory.get(key);
				if(key.equals("extends") ){
					if (value.equals("false")){
						flag = false;
					}
					continue;
				}
				extendResults.put(key, value);
			}
		}
		if(flag){
			results.putAll(extendResults);
		} else {
			return extendResults;
		}
		return results;
	}
	
	public String getIconCls() {
		return iconCls;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getState() {
		if(children==null||children.size()==0)
		{
			return null; 
		}
		else
		{
			return "open";
		}
	}
	public void setState(String state) {
		this.state = state;
	}
	
	@SuppressWarnings("rawtypes")
	public List getChildren() {
		return children;
	}
	
	@SuppressWarnings("rawtypes")
	public void setChildren(List children) {
		this.children = children;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getParentId() {
		return parentId;
	}
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}
	public String getMenuIndex() {
		return menuIndex;
	}
	public void setMenuIndex(String menuIndex) {
		this.menuIndex = menuIndex;
	}
	public boolean isChecked() {
		if(this.children != null && this.children.size() > 0){
			return false;
		} else {
			return checked;
		}
		
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public String getCheckedStr() {
		return checkedStr;
	}
	public void setCheckedStr(String checkedStr) {
		if("true".equals(checkedStr))
		{
			this.checked=true;
		}
		else
		{
			this.checked=false;
		}
		this.checkedStr = checkedStr;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getLastModifiedUser() {
		return lastModifiedUser;
	}
	public void setLastModifiedUser(String lastModifiedUser) {
		this.lastModifiedUser = lastModifiedUser;
	}
	public String getLastModifiedTime() {
		return lastModifiedTime;
	}
	public void setLastModifiedTime(String lastModifiedTime) {
		this.lastModifiedTime = lastModifiedTime;
	}
	public String getExcludeId() {
		return excludeId;
	}
	public void setExcludeId(String excludeId) {
		this.excludeId = excludeId;
	}
	public String[] getExcludeIds() {
		return excludeIds;
	}
	public void setExcludeIds(String[] excludeIds) {
		this.excludeIds = excludeIds;
	}
	public String getRolesId() {
		return rolesId;
	}
	public void setRolesId(String rolesId) {
		this.rolesId = rolesId;
	}
	public String[] getIds() {
		return ids;
	}
	public void setIds(String[] ids) {
		this.ids = ids;
	}
	@JSON(serialize=false)
	public Map<String, String> getSpecialHistory() {
		return specialHistory;
	}

	public void setSpecialHistory(Map<String, String> specialHistory) {
		this.specialHistory = specialHistory;
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}
	
}

